package com.peza.bikelog.common.domain.polar;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class HrmIntTimes implements Writable {

	
	private List<HrmInterval> intervals = new ArrayList<HrmInterval>();

	public HrmIntTimes(){
		
	}
	
	public HrmIntTimes(String data){
		List<String> rows = Arrays.asList(data.split("\n"));
		Iterator<String> i = rows.iterator();
		
		while (i.hasNext()){
			StringBuffer buffer = new StringBuffer();
			for (int j = 0; j < 5; j++){
				buffer.append(i.next()+"\n");
			}
			HrmInterval interval = new HrmInterval(buffer.toString());
			intervals.add(interval);
		}
		
	}

	
	@Override
	public String toFileString() {
		StringBuffer buffer = new StringBuffer("[IntTimes]\n");
		for (HrmInterval interval : intervals){
			buffer.append(interval.toFileString());
		}
		
		return buffer.toString() + "\n";
	}
	
	
}
